<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('交易列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="notice-form">
                <div class="select-list">
                    <ul>
                        <li>
                            哈希：<input type="text" name="hash" />
                        </li>
                        <li>
                            交易状态：<select name="tran_state">
                                <option value="">所有</option>
                                <option value="Y">成功</option>
                            </select>
                        </li>
                        <li>
                            卖出状态：<select name="is_sell">
                                <option value="">所有</option>
                                <option value="Y">已卖出</option>
                            </select>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="row">
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer"/>
    <script th:inline="javascript">
        var prefix = ctx + "coin/tran";

        $(function () {
            var options = {
                url: prefix + "/list",
                modalName: "交易列表",
                showSearch: false,
                showRefresh: false,
                showColumns: false,
                showToggle: false,
                columns: [{
                    checkbox: true
                },
                    {
                        field: 'id',
                        title: 'ID',
                    },
                    {
                        title: '币种信息',
                        formatter: function (value, row, index) {
                            var div = $.table.isnull("链路类型：", row.chain_type, "</br>");
                            div += $.table.isnull("币种名称：", row.symbol, "</br>");
                            div += $.table.isnull("合约地址：","<a target='_blank' href='https://ave.ai/token/"+row.token_address+"-"+row.chain_type+"'>"+ row.token_address_str+"</a>", "</br>");
                            div += $.table.isnull("所在钱包：","<a class='mt5' target='_blank' href='https://www.oklink.com/zh-hans/"+row.chain_type+"/address/"+row.user_address+"'>"+ row.user_address_str+"</a>", "</br>");
                            return div;
                        }
                    },
                    {
                        title: '买单信息',
                        formatter: function (value, row, index) {
                            var div = $.table.isnull("买入哈希：", "<a target='_blank' href='https://www.oklink.com/zh-hans/"+row.chain_type+"/tx/"+row.buy_hash+"'>"+ row.buy_hash_str+"</a>", "</br>");
                             div += $.table.isnull("买入时间：", row.buy_time, "</br>");
                             div += $.table.isnull("买入价格：", row.buy_price, "</br>");
                             div += $.table.isnull("预估价格：", row.buy_target_price, "</br>");

                            if(row.buy_tran_state !=null && row.buy_tran_state=='Y'){
                                div += $.table.isnull("<div class='mt5'>买入状态：", "<span class='badge badge-success mt3'>成功</span>", "</div>");
                            }else if(row.buy_tran_state !=null && row.buy_tran_state=='N'){
                                div += $.table.isnull("<div class='mt5'>买入状态：", "<span class='badge badge-danger'>失败</span>", "</div>");
                            }
                            return div;
                        }
                    },
                    {
                        title: '卖单信息',
                        formatter: function (value, row, index) {
                            var div = "";
                            if(row.sell_hash !=null && row.sell_hash !='-'){
                                div += $.table.isnull("卖出哈希：", "<a target='_blank' href='https://www.oklink.com/zh-hans/"+row.chain_type+"/tx/"+row.sell_hash+"'>"+ row.sell_hash_str+"</a>", "</br>");
                            }
                            div += $.table.isnull("卖出时间：", row.sell_time, "</br>");
                            div += $.table.isnull("卖出价格：", row.sell_price, "</br>");

                            if(row.sell_tran_state !=null && row.sell_tran_state=='Y'){
                                div += $.table.isnull("<div class='mt5'>卖出状态：", "<span class='badge badge-success mt3'>成功</span>", "</div>");
                            }else if(row.sell_tran_state !=null && row.sell_tran_state=='N'){
                                div += $.table.isnull("<div class='mt5'>卖出状态：", "<span class='badge badge-danger'>失败</span>", "</div>");
                            }
                            return div;
                        }
                    },
                    {
                        title: '备注',
                        formatter: function (value, row, index) {
                            var div = "";
                                div += $.table.isnull("跟单类型：", row.gdlx, "</br>");
                                div += $.table.isnull("净价格：", row.sub_price, "</br>");
                            return div;
                        }
                    }
                ]
            };
            $.table.init(options);
        });

    </script>
</body>

</html>